]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
locatePointer: Bind ripples creation to settings
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 30 Aug 2019 23:57:12 +0000 (01:57 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Mon, 9 Sep 2019 19:28:18 +0000 (19:28 +0000)
Don't create ripples if locate pointer is not enabled, and bind
creation to the relative desktop interface settings key.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/700

js/ui/locatePointer.js

index 10caa656d0e35d0c206e8414497285394f64f735..6ae29419a3decf59e617bc619a535b8f234342f3 100644 (file)
@@ -11,12 +11,26 @@ const LOCATE_POINTER_SCHEMA = "org.gnome.desktop.interface";
 var LocatePointer = class {
     constructor() {
         this._settings = new Gio.Settings({ schema_id: LOCATE_POINTER_SCHEMA });
-        this._ripples = new Ripples.Ripples(0.5, 0.5, 'ripple-pointer-location');
-        this._ripples.addTo(Main.uiGroup);
+        this._settings.connect(`changed::${LOCATE_POINTER_KEY}`, () => this._syncEnabled());
+        this._syncEnabled();
+    }
+
+    _syncEnabled() {
+        let enabled = this._settings.get_boolean(LOCATE_POINTER_KEY);
+        if (enabled == !!this._ripples)
+            return;
+
+        if (enabled) {
+            this._ripples = new Ripples.Ripples(0.5, 0.5, 'ripple-pointer-location');
+            this._ripples.addTo(Main.uiGroup);
+        } else {
+            this._ripples.destroy();
+            this._ripples = null;
+        }
     }
 
     show() {
-        if (!this._settings.get_boolean(LOCATE_POINTER_KEY))
+        if (!this._ripples)
             return;
 
         let [x, y] = global.get_pointer();